class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        
        sort(g.begin(),g.end());
        sort(s.begin(),s.end());
        int ret=0,m=g.size(),n=s.size();
        for(int i=0,j=0;i<m && j<n;i++,j++)
        {
            while(j<n && s[j]<g[i])j++;
            if(j<n)ret++;
        }
        return ret;
    }
};
